// 消息部分
import {request} from '../utils/request'
// const BASE_URL_MSG = "http://dev.message.lbs.p.yufeiworld.com" //消息 接口
// const BASE_URL_MSG = "http://dev.gateway.lbs.p.yufeiworld.com" //消息 接口
const BASE_URL_MSG = "" //消息 接口

// 删除消息
export const requestDelMessageById = (messageId: number) => {
    return request({
        url: BASE_URL_MSG + "/message/deleteById",
        method: "POST",
        header: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
        },
        data: {
            messageId
        }
    })
}

// 查询所有消息
export const requestSelectAll = () => {
    return request({
        url: BASE_URL_MSG + "/message/selectAll",
        method: "POST",
        header: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
        }
    })
}

export type DATA_MSG = {
    maxId: number // 消息编号最大值
    userId: number // 用户编号
}
// 查询某个用户最新消息
export const request_post_user_newMessage = (dataMsg: DATA_MSG) => {
    return request({
        url: BASE_URL_MSG + "/message/selectUserNewMessage",
        method: "POST",
        data: dataMsg
    })
}

// 更新消息为已读
export const request_post_update_msgStatus = (messageId: number) => {
    return request({
        url: BASE_URL_MSG + "/message/updateMsgStatus",
        method: "POST",
        header: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
        },
        data: {
            messageId
        }
    })
}